<template>
    <div>
            <Card>
                <p slot="title">
				    数据详情
			    </p>
                <div>
                    <Form class="step-form" ref="companyData" :model="companyData" :rules="companyDataRules" :label-width="100">
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="公司编号：" prop="company_code" label-position="left" :label-width="150">
                                   <Input :disabled="hasSubmit" v-model="companyData.company_code" type="text" placeholder="请输入公司编号" ></Input>
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="公司名称："  prop="long_name" label-position="left" :label-width="150">
                                     <Input :disabled="hasSubmit" v-model="companyData.long_name" type="text" placeholder="请输入公司名称" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="公司简称："  prop="short_name" label-position="left" :label-width="150">
                                    <Input :disabled="hasSubmit" v-model="companyData.short_name" type="text" placeholder="请输入公司简称" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="联系人："  prop="link_man" label-position="left" :label-width="150">
                                    <Input :disabled="hasSubmit" v-model="companyData.link_man" type="text" placeholder="请输入联系人名称" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="联系电话："  prop="link_phone" label-position="left" :label-width="150">
                                    <Input :disabled="hasSubmit" v-model="companyData.link_phone" type="text" placeholder="请输入联系人电话" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="api_url："  prop="api_url" label-position="left" :label-width="150">
                                    <Input :disabled="hasSubmit" v-model="companyData.api_url" type="text" placeholder="数据不能为空" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="api_key："  prop="api_key" label-position="left" :label-width="150">
                                    <Input :disabled="hasSubmit" v-model="companyData.api_key" type="text" placeholder="数据不能为空" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="api_secret："  prop="api_secret" label-position="left" :label-width="150">
                                    <Input :disabled="hasSubmit" v-model="companyData.api_secret" type="text" placeholder="数据不能为空" />
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row span="12">
                            <i-col span="12" >
                                <FormItem label="类型选择：" prop="app_type" label-position="left" :label-width="150">
                                   <Radio-group v-model="companyData.company_status">
                                        <Radio :label="0">关闭</Radio>
                                        <Radio :label="1">开启</Radio>
                                    </Radio-group>
                                </FormItem>
                            </i-col>
                        </Row>
                        
                        <FormItem >
                            <Button  @click="goBack" style="width:100px;" >返回</Button>
                        </FormItem>
                    </Form>
                </div>
            </Card>
    </div>
</template>

<script>
import ajax from '../../../libs/axios.js'
export default {
    name: 'addUser',
    data () {
        return {
            testModelShow:false,
            companyData: {
                company_code:'',
                long_name:'',//公司名称
                short_name:'',//公司简称
                link_man: '',//联系人
                link_phone:'',//联系电话
                api_url:'',
                api_key:'',
                api_secret:'',
                company_status:1,//公司状态
                oper_user:0
            },
            companyDataRules: {
                long_name: [
                    { required: true, message: '请输入公司名称', trigger: 'blur'},
                    {type: 'string', max: 20, message: '不能超过20个字符', trigger: 'blur'}
                ],
                short_name: [
                    { required: true, message: '请输入公司简称', trigger: 'blur'},
                    {type: 'string', max: 15, message: '不能超过15个字符', trigger: 'blur'}
                ],
                link_man: [
                    { required: true, message: '请输入联系人', trigger: 'blur'},
                    {type: 'string', max: 15, message: '不能超过15个字符', trigger: 'blur'}
                ],
                link_phone: [
                    { required: true, message: '请输入联系人', trigger: 'blur'}
                ]
            },
            hasSubmit: true
        }
    },
    methods: {
        // 数据初始化
        init () {
            let userId = window.localStorage.getItem('userId')
            this.$store.commit('setActiveName', 'companyindex')
            var id = this.$route.params.id
            this.selectById(id)
        },
        selectById(id){
            var _that = this;
            var url = '/adminlogin/transport/getTransportCompany';
            var data = {
                id: id
            };
       
            ajax.formRes(url, data).then(function (res) {
                if (200 == res.code) {
                    
                    _that.companyData = res.data;
                } else {
                    _that.$Message.success('数据原因，请联系管理员。');
                }
            }).catch(function (res) {
                console.log('有错误信息');
            });
        },
        goBack () {
            this.$router.push({
                name: 'companyindex'
            })
        }
        
    },
    created: function () {
        this.init()
    },
    activated: function () {
        //this.init()
    }
}
</script>
<style>
    .demo-upload-list-cover{
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,.6);
    }
    .card-upload:hover .demo-upload-list-cover{
        display: block;
    }
    .demo-upload-list-cover i{
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }
    .demo-spin-icon-load{
        animation: ani-demo-spin 1s linear infinite;
    }
    @keyframes ani-demo-spin {
        from { transform: rotate(0deg);}
        50%  { transform: rotate(180deg);}
        to   { transform: rotate(360deg);}
    }
    .demo-spin-col{
        height: 100px;
        position: relative;
        border: 1px solid #eee;
    }
</style>